]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
search: Simplify and correct behavior for substring searches
authorJasper St. Pierre <jstpierre@mecheye.net>
Sat, 16 Feb 2013 04:10:42 +0000 (23:10 -0500)
committerJasper St. Pierre <jstpierre@mecheye.net>
Sat, 16 Feb 2013 18:24:21 +0000 (13:24 -0500)
Early on, search was based on a list of terms, which was like a set
of tags, in that terms were OR'd, and that order didn't matter. As
such, modifying any one of the terms wouldn't produce new results.
Nowadays, providers take the order into account, so a substring
should only be the case if new terms are added to the end.

https://bugzilla.gnome.org/show_bug.cgi?id=693935

js/ui/search.js

index dced01c0475329505f21e6fae4e8b9da1a4ad0c6..c4eb10c2439d7d1c8d8670bcf08049bbaac82045 100644 (file)
@@ -64,15 +64,12 @@ const SearchSystem = new Lang.Class({
         if (!terms)
             return;
 
-        let isSubSearch = terms.length == this._previousTerms.length;
-        if (isSubSearch) {
-            for (let i = 0; i < terms.length; i++) {
-                if (terms[i].indexOf(this._previousTerms[i]) != 0) {
-                    isSubSearch = false;
-                    break;
-                }
-            }
-        }
+        let searchString = terms.join(' ');
+        let previousSearchString = this._previousTerms.join(' ');
+
+        let isSubSearch = false;
+        if (this._previousTerms.length > 0)
+            isSubSearch = searchString.indexOf(previousSearchString) == 0;
 
         let previousResultsArr = this._previousResults;